import java.util.Objects;

public class EqualsDemo05 {
    public static void main(String[] args) {

        // 如果两个金额一样，就认为同一个订单
        Order order = new Order(100, "手套");
        Order order1 = new Order(100, "手套");

//        System.out.println(order == order1);
//        System.out.println(order.equals(order1));
        System.out.println(order.equals(order1));

        // 如果两个金额一样 并订单名字一样，就是同一笔订单
    }
}

class Order {
    private float money;
    private String name;

    public Order(float money, String name) {
        this.money = money;
        this.name = name;
    }

    public float getMoney() {
        return money;
    }

    public void setMoney(float money) {
        this.money = money;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //重写equals

    public boolean equals(Order o) {
        if(this == o){
            return true;
        }
        if(o == null){
            return false;
        }
        return this.money == o.getMoney() && this.name.equals(o.getName());
    }





}



